

import schedule
import time
import requests


# https://schedule.readthedocs.io/en/stable/
def job():
    print("hello")

# https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=e9805dc3-b73d-4ee1-893d-1b4b6b871c28
def weixin_robot():
    print("wei_robot")
    weixin_hook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=e9805dc3-b73d-4ee1-893d-1b4b6b871c28"
    tip_json = {
    "msgtype": "text",
    "text": {
        "content": "Hi，小伙伴们，请及时填写今天的tpms项目工时，及处理待处理任务， tpms地址：https://tpms-cn.tuya-inc.com:7799",
        "mentioned_list":["@all"]
        }
    }
    resp =  requests.post(weixin_hook, json=tip_json)
    print(resp.status_code)

# https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=e9805dc3-b73d-4ee1-893d-1b4b6b871c28
def weixin_robot_shangwu():
    print("wei_robot")
    weixin_hook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=e9805dc3-b73d-4ee1-893d-1b4b6b871c28"
    tip_json = {
    "msgtype": "text",
    "text": {
        "content": "小伙伴们，上午好，请及时安排今天及近期的工作任务，tpms地址：https://tpms-cn.tuya-inc.com:7799",
        "mentioned_list":["@all"]
        }
    }
    resp =  requests.post(weixin_hook, json=tip_json)
    print(resp.status_code)


time1 = "10:30"
time2 = "18:15"
execute_job_shangwu = weixin_robot_shangwu
execute_job = weixin_robot

schedule.every().monday.at(time1).do(execute_job_shangwu)
schedule.every().tuesday.at(time1).do(execute_job_shangwu)
schedule.every().wednesday.at(time1).do(execute_job_shangwu)
schedule.every().thursday.at(time1).do(execute_job_shangwu)
schedule.every().friday.at(time1).do(execute_job_shangwu)

schedule.every().monday.at(time2).do(execute_job)
schedule.every().tuesday.at(time2).do(execute_job)
schedule.every().wednesday.at(time2).do(execute_job)
schedule.every().thursday.at(time2).do(execute_job)
schedule.every().friday.at(time2).do(execute_job)

while True:
    schedule.run_pending()
    time.sleep(1)